package main

import (
	"embed"
	"github.com/gin-gonic/gin"
	"net/http"
	"server-admin-api/global"
	"server-admin-api/initialization"
	"time"
)

//go:embed resources/html
var html embed.FS

func main() {

	global.DB = initialization.InitSqlite()

	gin.ForceConsoleColor()

	gin.SetMode(gin.DebugMode)

	engine := gin.Default()

	initialization.InitResource(engine)


	server := &http.Server{
		Addr:           ":8080",
		Handler:        initialization.InitRouter(engine, html, true),
		ReadTimeout:    10 * time.Second,
		WriteTimeout:   10 * time.Second,
		MaxHeaderBytes: 1 << 20,
	}

	server.ListenAndServe().Error()

	//mux := http.DefaultServeMux
	//
	//mux.Handle("/web/", api.AssetHandler("/", html, "./resources/html"))
	//
	//log.Fatal(http.ListenAndServe(":8080", mux))
}



